package com.qf.jie.dao.impl;

import com.qf.jie.dao.OrderDao;
import com.qf.jie.entity.po.Order;
import com.qf.jie.utils.DBUtils;

import java.util.Date;
import java.util.List;
//(Integer id, Long datetime, Integer commodity_id, Integer user_id_0, Integer user_id_1, Integer status, String address, String phone)
public class OrderDaoImpl implements OrderDao {


    @Override
    public int addBean(Order order) {
        return DBUtils.excuteUpdate("insert into `order`(datetime,commodity_id,user_id_0,user_id_1,status,address,phone) values(?,?,?,?,?,?,?)",
                order.getDatetime(),order.getCommodity_id(),order.getUser_id_0(),order.getUser_id_1(),order.getStatus(),order.getAddress(),order.getPhone()
                );
    }

    @Override
    public int updateStatusById(int status, int id) {
        return DBUtils.excuteUpdate("update `order` set status = ? where id = ?", status, id);
    }

    @Override
    public List<Order> getOrderListByUserId_0(int user_id_0) {
        return DBUtils.excuteQuery(Order.class, "select * from `order` where user_id_0=?", user_id_0);
    }

    @Override
    public List<Order> getOrderListByUserId_1(int user_id_1) {
        return DBUtils.excuteQuery(Order.class, "select * from `order` where user_id_1=?", user_id_1);
    }

    @Override
    public int deleteById(int id) {
        return 0;
    }

    @Override
    public int updateById(Order order) {
        return 0;
    }

    @Override
    public int shamDeleteById(int id) {
        return 0;
    }

    @Override
    public int getCount() {
        return 0;
    }

    @Override
    public int getIdByName(String name) {
        return 0;
    }

    @Override
    public int getCountByName(String name) {
        return 0;
    }

    @Override
    public int getIdByNameAndPassword(String name, String password) {
        return 0;
    }

    @Override
    public List<Order> getList() {
        return null;
    }

    @Override
    public List<Order> getList(int start, int len) {
        return null;
    }

    @Override
    public List<Order> getListLike(String name) {
        return null;
    }

    @Override
    public List<Order> getBeanById(int id) {
        return DBUtils.excuteQuery(Order.class, "select * from `order` where id=?", id);
    }
}
